//
//  FirstUseViewController.m
//  BeeQuick
//
//  Created by Vivitickey on 2017/5/8.
//  Copyright © 2017年 test. All rights reserved.
//

#import "FirstUseViewController.h"
#import "BQLanuchFlowLayout.h"
#import "BQFirstUseCell.h"
@interface FirstUseViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,BQLanuchFlowLayoutDelegate>

@property (nonatomic,weak) UIPageControl *pageControl;

@end
static NSString *first_cell = @"first_cell";
@implementation FirstUseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
    
}



-(void)setupUI{
    
    BQLanuchFlowLayout *flowLayout = [[BQLanuchFlowLayout alloc]init];
    
    flowLayout.delegate = self;
    
    UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:flowLayout];
    
    collectionView.delegate = self;
    
    collectionView.dataSource = self;
    
    collectionView.pagingEnabled = YES;
    
    collectionView.showsHorizontalScrollIndicator = NO;
    
    [self.view addSubview:collectionView];
    
    [collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.offset(0);
    }];
    
    [collectionView registerNib:[UINib nibWithNibName:@"BQFirstUseCell" bundle:nil] forCellWithReuseIdentifier:first_cell];
    
    UIPageControl *pageControl = [[UIPageControl alloc]init];
    
    _pageControl = pageControl;
    
    [self.view addSubview:pageControl];
    
    [pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        
        make.bottom.offset(-10);
    }];
    
    pageControl.numberOfPages = 4;
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return 4;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    BQFirstUseCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:first_cell forIndexPath:indexPath];
    
    cell.backgroundImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"guide_40_%zd",indexPath.row + 1]];
    
    if (indexPath.row == 3) {
        cell.clickButton.hidden = NO;
    }else{
    
        cell.clickButton.hidden = YES;
    }
    
    return cell;
}




- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout cellCenteredAtIndexPath:(NSIndexPath *)indexPath page:(int)page{
    self.pageControl.currentPage = page; // 分页控制器当前显示的页数
}


@end
